﻿@model List<_8_21_Homework.Models.Post>
@{
    ViewBag.Title = "Home Page";
}

<div class="jumbotron" style="background-color:darkslategrey; color:antiquewhite">
    <h1>This is my blog</h1>
</div>
Search For Post:
<div>
    <input class="col-md-4" id ="searchInput" type="text" placeholder="Search By Post Title" onkeyup="location.href='/Home/SearchFor/'+document.getElementById('searchInput')"/>
</div>
<br /><br />
<div id="wrapper">
    @foreach (var post in Model)
    {
        <div class="row table-bordered">
            <div class="col-md-4" onclick="location.href='/Home/PostDetail/@post.ID'">
                <h1 class="jumbotron" id="titleHover">@post.Title</h1>
            </div>
            <div class="col-md-6 text-center">
                <br /><br /><br />
                <div class="row">
                    @{
        var count = 0;
        var snippet = "";
        foreach (var b in @post.Body)
        {
            snippet += b;
            count++;
            if (count == 250) { break; }
        }
        if (@post.Body.Length > 250)
        {
            snippet += "...   ";
        }
        <div>
            @snippet
            @if (@post.Body.Length > 250)
            {
                <a href="/Home/PostDetail/@post.ID">more</a>
            }
        </div>

        snippet = "";
                    }

                </div>
                @*<button class="btn-primary pull-right" onclick="location.href='/Home/PostDetail/@post.ID'">View Post</button>*@
            </div>
            <div class="col-md-2">
                <button class="btn-danger pull-right" onclick="location.href='/Home/Delete/@post.ID'">Delete</button>
                <button class="btn-warning pull-right" onclick="location.href='/Home/EditPost/@post.ID'">Edit</button>
            </div>
            <span class="pull-right">@post.DateCreated</span>
        </div>

    }

</div>